package com.netease.examination.dao.seller;

import com.netease.examination.model.Goods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * designed by destiny
 *
 * @author destiny
 *         e-mail destinywk@163.com
 *         github https://github.com/DestinyWang
 *         oschina https://git.oschina.net/destinywk
 * @version JDK 1.8.0_101
 * @since 2017/3/30 22:00
 */
@Mapper
public interface GoodsDAO {

    @Insert({"INSERT INTO tb_goods (title, summary, img_url, content, price, tag) VALUES " +
            "(#{title}, #{link}, #{imgUrl}, #{content}, #{price}, #{tag})"})
    public Integer insertGoods(Goods goods);

    @Update({"UPDATE tb_goods SET " +
            "title = #{title}, summary = #{summary}, img_url = #{imgUrl}, content = #{content}, " +
            "price = #{price}, tag = #{tag} WHERE id = #{id}"})
    public Integer updateGoods(Goods goods);

    @Select({"SELECT id, title, summary, img_url AS imgUrl, content, price, tag FROM tb_goods WHERE id = #{id}"})
    public Goods getById(Long id);

}
